<?php

if(!tep_session_is_registered('sppc_customer_group_id')) { 
      $customer_group_id = '0';
      } else {
      $customer_group_id = $sppc_customer_group_id;
   }

  $info_box_contents = array();
  //puts title in the upper left corner of the new products box
  $info_box_contents[] = array('text' => sprintf(BOX_HEADING_HOMEPAGE_CATEGORIES, strftime('%B')));
  $a['newcathead'] = sprintf(BOX_HEADING_HOMEPAGE_CATEGORIES, strftime('%B'));

  $categories_query =tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0 order by sort_order, cd.categories_name");

  $num = mysql_num_rows($categories_query);

      //variables to put the category images in rows and columns
      $row = 0;
      $col = 0;
		$nc = 0;
      while($num)//keep doing while there catgories
      {    
      $nc++;
        $rows =  mysql_fetch_array($categories_query);
        @$catID_new =tep_get_path($rows['categories_id']);//error suppressor was need in cPanel but not DirectAdmin
        $new_products['products_name'] = tep_get_products_name($rows['categories_name']);    
        $info_box_contents[$row][$col] = array('align' => 'center',
                                           'params' => 'class="smallText" width="33%" valign="middle"',
                                           'text' => '<a href="' . tep_href_link(FILENAME_DEFAULT, $catID_new) .
                                           '">'.tep_image(DIR_WS_IMAGES . $rows['categories_image'],
                                           $rows['categories_name'],
                                           SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT). '</a>'.'<br>'.//may want to tinker with this line to find the right image size for you
                                           '<a href="' .tep_href_link(FILENAME_DEFAULT, $catID_new) .'">'.
                                           $rows['categories_name'].'</a>'.'<br>');
		$a['catdispimg'][$nc] = '<a href="' . tep_href_link(FILENAME_DEFAULT, $catID_new) .
                                           '">'.tep_image(DIR_WS_IMAGES . $rows['categories_image'],
                                           $rows['categories_name'],
                                           SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT). '</a>';
        $a['catdispname'][$nc] = '<a href="' .tep_href_link(FILENAME_DEFAULT, $catID_new) .'">'.
                                           $rows['categories_name'].'</a>';
                                           
        $col ++;
        if ($col > 2)
        {
          $col = 0;
          $row ++;      
          $a['catsetrow'][$nc] = '</tr><tr>';
        }
        $mainframe->appendMetaTag( 'keywords', $rows['categories_name'] );
        $num--;//keep subtracting until we're out of categories
      }       
      $nc++;
      defined( 'ECJC_VALID_CONTROLLER' ) or die( 'Direct Access to this location is not allowed.' );
      //new contentBox($info_box_contents);   
      require(WS_TEMPLATES . E_TEMPLATE_FOLDER . '/new_categories.html');
    ?>